<?php
    $status = array('Pendiente', 'En Progreso', 'Pendiente con cliente', 'Cambios', 'Mas Información', 'Aprobado', 'Entregado');
?>
<h3>&nbsp;&nbsp;&nbsp;&nbsp;Comentarios sobre &Colon; <?php echo $this->name_job ?><img class="loading" src="<?php echo $this->baseUrl() ?>/public/img/loader.gif" style="display: none" width="24"/> </h3>
<div class="module_content">
    <form id="custom-orden-comment" method="POST" action="<?php echo $this->url(array('module' => 'orden', 'controller' => 'index', 'action' => 'save-comment')) ?>">
        <table>
            <tr>
                <td>
                    <input type="hidden" id="id_orden" name="id_orden" value="<?php echo $this->id_orden ?>"/>
                    <input type="hidden" id="id_job" name="id_job" value="<?php echo $this->id_job ?>"/>
                    <select id="status" name="status" style="width: 150px">
                        <option value="0">-Seleccione el estado-</option>
                        <option value="2">Pendiente con cliente</option>
                        <option value="3">Cambios</option>
                        <option value="5">Aprobado</option>
                        <option value="6">Entregado</option>
                    </select>
                </td>
                <td style="width: 80px">
                    <textarea id="detail" name="detail" style="width: 200px; height: 50px; resize: none;"></textarea>
                </td>
                <td>
                    <input type="submit" id="ok" name="ok" value="OK"/>
                </td>
            </tr>
        </table>
    </form>

    <table id="grid_comment" class="gridtable" style="width: 400px">
        <thead>
        <th>Mensaje</th>
        <th>Estado</th>
        <th>Fecha</th>
        <th>Usuario</th>
        </thead>
        <tbody>
            <?php foreach ($this->resultJobActivity as $msg) : ?>
                <tr>
                    <td><?php echo $msg->message ?></td>
                    <td><?php echo $status[$msg->status] ?></td>
                    <td><?php echo $msg->register_date ?></td>
                    <td><?php echo $msg->nombre . ' ' . $msg->apellidos ?></td>
                </tr>     
            <?php endforeach; ?>
        </tbody>
    </table>
</div>


<script language="javascript">
    var status = ['Pendiente', 'En Progreso', 'Pendiente con cliente', 'Cambios', 'Mas Información', 'Aprobado', 'Entregado'];
    $(".inline").colorbox({height:'450px'});
   
    $('#custom-orden-comment').ajaxForm({
        dataType:  'json',
        beforeSend: function() {
            $('.loading').css('display', 'block');
        },
        complete: function(xhr) {
            $('.loading').css('display', 'none');
        },
        success: function(data){
            $('#grid_comment tr:last').after('<tr><td>'+ data.message +'</td><td>'+ status[parseInt(data.status,10)].toString() +'</td><td>'+ data.register_date +'</td><td>'+ data.nombre+' '+ data.apellidos +'</td></tr>');
        } 
    }); 
    $('#custom-orden-comment').validate({
        errorPlacement: function(error, element) {
            $('#custom-orden div.stepy-error').append(error);
        }, rules: {
            'status':	'required',
            'detail':	'required'
        }, messages: {
            'status':	{ required: '*Seleccione el estado' },
            'detail':	{ required: '*Ingrese el detalle' }
        }
    });
</script>